/**
 * 
 */
package ru.athena.runTool.Model;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import ru.athena.runTool.LogWriter;
import ru.athena.runTool.RunToolView;

public class OperationShowProgress implements Operation {
	RunToolView		view_;
	
	/**
	 * @param view_
	 */
	public OperationShowProgress(RunToolView view) {
		this.view_ = view;
	}
	
	
	/**
	 * send an event about starting node processing
	 */
	public void visit(LeafNode node) throws Exception {
		processNode(node);
	}

	public void visitEnter(CompositeNode node) throws Exception {
		processNode(node);
	}

	public void visitLeave(CompositeNode node) throws Exception {
		
	}

	/**
	 * @param node
	 */
	private void processNode(AbstractNode node) {
		view_.setSelectedNode( new TreePath( ((DefaultMutableTreeNode) node).getPath()) );
		view_.addStatusText( LogWriter.extractText() );
	}

}